package com.abc.http.example.common.model;

import lombok.Data;

/**
 * @description: 基础
 * @author: yansl.cn
 * @create: 2023-01-16 17:19
 */
@Data
public class HttpResult<T> {
    /** 失败 */
    public static final String FAILURE = "0";
    /** 成功 */
    public static final String SUCCESS = "1";

    /** 返回状态 */
    private String status;
    /** 返回结果 */
    private T rs;

    /** 错误代码(移动端用) */
    private String errcode;
    /** 错误消息 */
    private String errmsg;

    public HttpResult() {
    }

    public HttpResult(String code) {
        this.setStatus(code);
    }

    public HttpResult(String code, T t) {
        this.setRs(t);
        this.setStatus(code);
    }

    public static HttpResult err(String errmsg) {
        return new HttpResult(FAILURE, errmsg);
    }

    public static <T> HttpResult<T> OK(T t) {
        return new HttpResult(SUCCESS, t);
    }

}
